#include "recipe.h"
#include<QSqlQuery>
#include<QVariant>

Recipe::Recipe()
{
}

Recipe::Recipe(int id)
{
    QSqlQuery query;
    query.exec("SELECT * FROM Recipe WHERE id="+QString::number(id)+";");
    query.next();
    this->id=query.value(0).toInt();
    this->name = query.value(1).toString();
    this->type = query.value(2).toString();
    this->preparation = query.value(3).toString();
    this->userScore = query.value(4).toInt();
    this->vegetarian = query.value(5).toBool();
    this->dificulty = query.value(6).toString();
    this->time = query.value(7).toString();
    this->cal_level = query.value(8).toString();
    this->serves = query.value(9).toInt();
}

int Recipe::evaluate(){
    int t1=0,t2=0,t3=0,t4=0;
    //evaluar fechas de vencimiento

    //evaluar nivel de calorias
    //evaluar gustos del usuario
    t3=this->userScore;
    //evaluar repitencia de preparacion
    t3=qrand()%1000;
    return t1+t2+t3+t4;
}
